package com.dianxin.smartpark.web.dic;

import com.chinatelecom.response.common.CommonResponseBody;
import com.dianxin.acl.api.dic.DataDicRpcService;
import com.dianxin.acl.api.dto.DataGroupDTO;
import com.dianxin.acl.api.dto.DataGroupDicDTO;
import com.dianxin.acl.api.qo.DataGroupDicRpcQO;
import com.dianxin.acl.api.qo.DataGroupRpcQO;
import com.dianxin.common.cache.service.RedisService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 字典以及字典组服务
 *
 * @Author wangkai
 * @Date 2021/8/2 4:01 下午
 */
@RestController
@RequestMapping("/smartpark/data")
public class SmartParkDicController {

    @Resource
    private DataDicRpcService dataDicRpcService;
    @Resource
    private RedisService redisService;

    /**
     * 查询字典组
     *
     * @param qo qo
     * @return
     */
    @RequestMapping("/getGroupList")
    public CommonResponseBody<List<DataGroupDTO>> getGroupList(@RequestBody DataGroupRpcQO qo) throws Exception {

        return dataDicRpcService.getGroupList(qo);
    }

    /**
     * 更新字典组
     *
     * @param dto qo
     * @return
     */
    @RequestMapping("/udpateGroup")
    public CommonResponseBody<Boolean> udpateGroup(@RequestBody DataGroupDTO dto) throws Exception {

        return dataDicRpcService.updateGroup(dto);
    }

    /**
     * 删除字典组
     *
     * @param dto qo
     * @return
     */
    @RequestMapping("/delGroup")
    public CommonResponseBody<Boolean> delGroup(@RequestBody DataGroupDTO dto) throws Exception {

        return dataDicRpcService.delGroup(dto);
    }

    /**
     * 保存字典组
     *
     * @param dto qo
     * @return
     */
    @RequestMapping("/saveGroup")
    public CommonResponseBody<Boolean> saveGroup(@RequestBody DataGroupDTO dto) throws Exception {

        return dataDicRpcService.saveGroup(dto);
    }


    /**
     * 保存字典详情
     *
     * @param dto 字典组code 必传
     * @return
     */
    @RequestMapping("/saveGroupDic")
    public CommonResponseBody<Boolean> saveGroup(@RequestBody DataGroupDicDTO dto) throws Exception {

        return dataDicRpcService.saveGroupDic(dto);
    }

    /**
     * 更新字典详情
     *
     * @param dto 字典组code 必传  以及各个id必传
     * @return
     */
    @RequestMapping("/updateGroupDic")
    public CommonResponseBody<Boolean> updateGroupDic(@RequestBody DataGroupDicDTO dto) throws Exception {

        return dataDicRpcService.updateGroupDic(dto);
    }

    /**
     * 删除字典详情
     *
     * @param dto 字典组code 必传 以及各个id必传
     * @return
     */
    @RequestMapping("/delGroupDic")
    public CommonResponseBody<Boolean> delGroupDic(@RequestBody DataGroupDicDTO dto) throws Exception {

        return dataDicRpcService.delGroupDic(dto);
    }

    /**
     * 获取字典详情
     *
     * @param qo 字典组code 必传
     * @return
     */
    @RequestMapping("/getGroupDicList")
    public CommonResponseBody<List<DataGroupDicDTO>> getGroupDic(@RequestBody DataGroupDicRpcQO qo) throws Exception {

        return dataDicRpcService.getGroupDicList(qo);
    }


}
